package be.jabapage.snooker.service.competition.api;

import java.util.Set;

import be.jabapage.snooker.exception.EntityNotFoundException;
import be.jabapage.snooker.exception.MultipleInstanceFoundException;
import be.jabapage.snooker.jdo.competition.SubCompetition;

/**
 * 
 * CRUD service for the SubCompetition
 * @author axesq
 *
 */
public interface ISubCompetitionService {

	/**
	 * 
	 * Store or update a SubCompetition in the data store
	 * @param SubCompetition
	 */
	void store(SubCompetition subCompetition);

	/**
	 * Retrieve a SubCompetition by the key
	 * @param key
	 * @return SubCompetition
	 * @throws EntityNotFoundException when no record is found
	 */
	SubCompetition retrieve(Long key) throws EntityNotFoundException;

	/**
	 * Delete the instance with this key from the datastore.
	 * @param key
	 * @throws EntityNotFoundException when the instance is not found;
	 */
	void delete(Long key) throws EntityNotFoundException;

	/**
	 * Retrieve a SubCompetition by the name
	 * @param name
	 * @return
	 * @throws MultipleInstanceFoundException when more then one instance is found.
	 * @throws EntityNotFoundException when no record is found
	 */
	SubCompetition retrieve(String name) throws MultipleInstanceFoundException, EntityNotFoundException;

	/**
	 * Retrieves a list of SubCompetition depending on the search criteria.  Wildcards are allowed.
	 * @param name
	 * @return a {@link Set}
	 */
	Set<SubCompetition> search(String name);

	/**
	 * Retrieves a set of SubCompetition that belongs to a certain region.
	 * @param competitionId
	 * @return
	 */
	Set<SubCompetition> retrieveAllForCompetition(Long competitionId);
}
